<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <MenuComponent></MenuComponent>
      </el-aside>
      <el-container>
        <el-header
          style="
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 20px;
          "
          >{{ route.meta.title }}
          <el-popconfirm title="确定退出登录吗?" @confirm="logout">
            <template #reference>
              <button class="logoutBtn">退出登录</button>
            </template>
          </el-popconfirm></el-header
        >

        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script setup lang="ts">
import MenuComponent from './MenuComponent.vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const logout = () => {
  localStorage.removeItem('token')
  localStorage.removeItem('userInfo')
  router.push('/login')
}
</script>
<style scoped lang="scss">
.common-layout {
  height: 100vh;
  width: 100vw;
}

.el-container {
  height: 100%;
  width: 100%;
}

.logoutBtn {
  border: none;
  background-color: #f1f8fd;
  color: #7ab3f5;
  width: 10%;
  height: 50%;
  border-radius: 20%;
  cursor: pointer;
}
</style>
